/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.yunhoo.asset.util;

//import com.yunhoo.pay.model.Expense;
import com.yunhoo.pay.model.Expense;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author Administrator
 */
public class PayCodeConstants {
    /*
    功能分类常量
     */

    public static Map<String, String> functionType() {
        Map<String, String> func = new HashMap<String, String>();
        func.put("人员经费", "2170150");
        func.put("公用经费", "2170150");
        func.put("住房公积金", "2210201");
        func.put("提租补贴", "2210202");
        func.put("购房补贴", "2210203");
        func.put("办公用房租及物业费", "2170102");
        func.put("信息系统建设及运行费", "2170206");
        func.put("专项业务费", "2179901");
        func.put("个人账户管理费", "2179901");
        func.put("绩效奖金", "2179901");
        func.put("机动经费", "2179901");
        return func;
    }

    public static Map<String, String> costType() {
        Map<String, String> cost = new HashMap<String, String>();
        cost.put("货物政府采购支出", "1");
        cost.put("工程政府采购支出", "2");
        cost.put("服务政府采购支出", "3");
        cost.put("货物非政府采购支出", "4");
        cost.put("工程非政府采购支出", "5");
        cost.put("服务非政府采购支出", "6");
        cost.put("转移支付", "7");
        cost.put("工资支出", "8");
        return cost;
    }

    public static Map<String, String> projCode() {
        Map<String, String> proj = new HashMap<String, String>();
        proj.put("办公用房租及物业费", "1270800000001");
        proj.put("信息系统建设及运行费", "1271100000004");
        proj.put("专项业务费", "1270800000002");
        proj.put("个人账户管理费", "1270800000003");
        proj.put("绩效奖金", "1271100000005");
        proj.put("机动经费", "1271100006001");
        return proj;
    }

    public static Map<String, String> eocCode() {
        Map<String, String> eoc = new HashMap<String, String>();
        eoc.put("工资福利支出", "301");
        eoc.put("商品和服务支出", "302");
        eoc.put("对个人家庭的补助", "303");
        eoc.put("对企事业单位的补助", "304");
        eoc.put("专移性支出", "305");
        eoc.put("赠与", "306");
        eoc.put("债务利息支出", "307");
        eoc.put("债务还本支出", "308");
        eoc.put("其他资本性支出", "310");
        eoc.put("贷款转贷及产权参股", "311");
        eoc.put("其他支出", "399");
        return eoc;
    }

    public static String buildPayCode(Expense exp) {
        String code = "";

        if (exp.getCostClass().trim().equalsIgnoreCase("基本支出")) {
            code += "1";
        }
        if (exp.getCostClass().trim().equalsIgnoreCase("项目支出")) {
            code += "2";
        }
        code += functionType().get(exp.getProjCode());
        //code += "000";
        //经济分类
        code += exp.getEocCode().trim();
        code += costType().get(exp.getCostType());
        if (exp.getBudgetSource().trim().equalsIgnoreCase("当年预算")) {
            code += "1";
        }
        if (exp.getBudgetSource().trim().equalsIgnoreCase("上年结余")) {
            code += "2";
        }
        code += PayCodeConstants.projCode().get(exp.getProjCode());
        return code;
    }

    public static String buildPayCodeForBill(Expense exp) {
        String code = "";
        if (exp.getCostClass().trim().equalsIgnoreCase("基本支出")) {
            code += "1";
        }
        if (exp.getCostClass().trim().equalsIgnoreCase("项目支出")) {
            code += "2";
        }
        if (exp.getPayStyle().getName().trim().equalsIgnoreCase("现金")) {
            code += "1";
        }
        if (exp.getPayStyle().getName().trim().equalsIgnoreCase("支票")) {
            code += "2";
        }

        code += exp.getNumber().trim();
        return code;
    }

    public static String buildPayCodeForLoanBill(Expense exp) {
        String code = "";
        System.out.println("paycode:" + code);
        //基本支出
        if (exp.getCostClass().trim().equalsIgnoreCase("0")) {
            code += "1";
        }
        //项目支出
        if (exp.getCostClass().trim().equalsIgnoreCase("1")) {
            code += "2";
        }
        //code += convertString(exp.getProject().getFinCode()).trim();
        code += convertString(exp.getProject().getBudgetCode()).trim();
        code += convertString(exp.getCostitem().getCode()).trim();
        if (exp.getBudgetSource().trim().equalsIgnoreCase("当年预算")) {
            code += "1";
        }
        if (exp.getBudgetSource().trim().equalsIgnoreCase("上年结余")) {
            code += "2";
        }
        //code += convertString(exp.getProject().getMofProjCode()).trim();
        System.out.println("paycode:" + code);
        System.out.println("budgetCode:" + exp.getProject().getBudgetCode().trim());
        return code;
    }

    public static Map<String, String> useStatus() {
        Map<String, String> numsta = new HashMap<String, String>();
        numsta.put("0", "在用");
        numsta.put("1", "报废");
        numsta.put("2", "报损");
        numsta.put("3", "其他");
        return numsta;
    }
    public static String convertString(String str) {
        return str == null ? "" : str;
    }

    public static double convertDouble(Double num) {
        return num == null ? 0.0 : num;
    }

    public static Date convertDate(Date date) {
        return date == null ? null : date;
    }

    public static Map<String, String> functionVoutype() {
        Map<String, String> cost = new HashMap<String, String>();
        cost.put("3", "借款单");
        cost.put("0", "报销单");
        cost.put("1", "差旅费报销单");
        return cost;
    }

    public static Map<String, String> functionNumberStatus() {
        Map<String, String> numsta = new HashMap<String, String>();
        numsta.put("0", "已提交等待审核");
        numsta.put("1", "未提交");
        numsta.put("2", "审核通过等待支付");
        numsta.put("3", "退回修改");
        numsta.put("4", "支付成功");
        numsta.put("5", "撤单");
        return numsta;
    }
    public static Map<String, String> formateCostClass() {
        Map<String, String> numsta = new HashMap<String, String>();
        numsta.put("0", "基本支出");
        numsta.put("1", "项目支出");
        return numsta;
    }
}
